package com.ikun.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import com.ikun.entity.Complaints;
import com.ikun.service.ComplaintsService;
import com.ikun.util.Result;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;

/**
 * @ClassName: ComplaintsController
 * @Author: 吴思伟
 * @CreateTime: 2025-03-26 10:08
 * @Description: 投诉管理相关
 */
@Controller
@RequestMapping("/complaints")
@Tag(name = "投诉模块", description = "投诉相关接口")
public class ComplaintsController {
    @Autowired
    private ComplaintsService complaintsService;

    @GetMapping("/all")
    @ResponseBody
    @Operation(summary = "查询所有投诉信息", description = "查询所有投诉信息")
    public Result showAllComplaints() {
        return Result.success(complaintsService.findAllComplaints());
    }

    @GetMapping("/content")
    @ResponseBody
    @Operation(summary = "根据内容查询投诉信息", description = "根据投诉内容模糊查询投诉信息")
    public Result showComplaintsByContent(String keyWord) {
        System.out.println("keyWord = " + keyWord);
        return Result.success(complaintsService.findByContent(keyWord));
    }

    @PostMapping("/add")
    @ResponseBody
    @Operation(summary = "提交投诉信息", description = "提交投诉信息")
    public Result addComplaints(@RequestBody Complaints complaints) {
        return Result.success(complaintsService.addComplaints(complaints));
    }

}
